Q: What is order of resultant heap after merging two tree of order k?
Solution: This could be easily verified by looking at the structure of a binomial heap.
Q: Time taken in decreasing the node value in a binomial heap is
Solution: Decreasing a node value may result in violating the min property. As a result be there would be exchange in the value of parent and child which at max goes up to height of the heap.
Q: What does this pseudo_code return ? int myfun(heap_arr[]) { int mini=INF; for(int i=0;i
Solution: The function return minimum value in the heap_Array which is equal to the root value of the heap.
Q: Which of these operations have same complexities?
Solution: With proper implementation using link list find_min and find_max operation can be done in O(1), while the remaining takes O(logn) time.
Q: Given a heap of n nodes.The maximum number of tree for building the heap is.
Solution: Each node could be seen as a tree with only one node and as a result maximum subtree in the heap is equal to number of nodes in the heap.
Q: Choose the option with function having same complexity for a fibonacci heap.
Solution: For a fibonacci heap insertion, union take O(1) while remaining take O(logn) time.
Q: What is wrong with the following code of insertion in fibonacci heap. Choose the correct option FIB-INSERT(H, x) degree[x]= 0 p[x]= NIL child[x] =NIL left[x] =x right[x] =x mark[x] =FALSE concatenate the root list containing x with root list H if min[H] = NIL or key[x] > key[min[H]] then min[H]= x n[H]= n[H] + 1
Solution: The main characterstics of a fibonacci heap is violated since min[H] must conatin one with smallest value.
Q: What will be the order of new heap created after union of heap H1 and H2 when created by the following code.Initially both are of the order n. FIB_UNION(H1,H2) { H =MAKE_HEAP() min[H]= min[H1] concatenate the root list of H2 with the root list of H if (min[H1] = NIL) or (min[H2]!= NIL and min[H2] < min[H1]) then min[H] = min[H2] n[H]= n[H1] + n[H2] free the objects H1 and H2 return H }
Solution: Union of two trees increase the order of the resultant by atmost value 1.
You Have Score    | /8 |